package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtQuestionHistory;
import com.rt.system.service.IRtQuestionHistoryService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 试题日志记录Controller
 * 
 * @author Yg
 * @date 2022-04-13
 */
@RestController
@RequestMapping("/system/history")
public class RtQuestionHistoryController extends BaseController
{
    @Autowired
    private IRtQuestionHistoryService rtQuestionHistoryService;

    /**
     * 查询试题日志记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtQuestionHistory rtQuestionHistory)
    {
        startPage();
        List<RtQuestionHistory> list = rtQuestionHistoryService.selectRtQuestionHistoryList(rtQuestionHistory);
        return getDataTable(list);
    }

    /**
     * 导出试题日志记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "试题日志记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtQuestionHistory rtQuestionHistory)
    {
        List<RtQuestionHistory> list = rtQuestionHistoryService.selectRtQuestionHistoryList(rtQuestionHistory);
        ExcelUtil<RtQuestionHistory> util = new ExcelUtil<RtQuestionHistory>(RtQuestionHistory.class);
        return util.exportExcel(list, "试题日志记录数据");
    }

    /**
     * 获取试题日志记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return AjaxResult.success(rtQuestionHistoryService.selectRtQuestionHistoryByLogId(logId));
    }

    /**
     * 新增试题日志记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "试题日志记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtQuestionHistory rtQuestionHistory)
    {
        return toAjax(rtQuestionHistoryService.insertRtQuestionHistory(rtQuestionHistory));
    }

    /**
     * 修改试题日志记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "试题日志记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtQuestionHistory rtQuestionHistory)
    {
        return toAjax(rtQuestionHistoryService.updateRtQuestionHistory(rtQuestionHistory));
    }

    /**
     * 删除试题日志记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "试题日志记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(rtQuestionHistoryService.deleteRtQuestionHistoryByLogIds(logIds));
    }
}
